/*******************************************************************************
**
** Copyright (c) 2011 - The OWE Team
**
** This file is part of OWE.
**
** OWE is a free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; version
** version 2.1 of the License.
**
** OWE is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with OWE. If not, see <http://www.gnu.org/licenses/>.
**
*******************************************************************************/

#ifndef UTESTS_H
#define UTESTS_H

#include <map>

#include <owe/node.h>
#include <owe/ustring.h>

OWE_USE_NAMESPACE

class OWE_EXPORT FakeNode : public Node
{
public:
    FakeNode(const char *name = 0, const char *data = 0);
    ~FakeNode();

    UString name() const { return m_name; }
    UString data() const { return m_data; }

    UString attribute(const char *attributeName) const;
    void addAttribute(const char *attribute, const char *value = 0);

private:
    UString m_name;
    UString m_data;

    std::map<UString, UString> m_attribute;
};

#ifdef __GNUC__
// Classic stringification as described at GCC pre processor docs:
// http://gcc.gnu.org/onlinedocs/cpp/Stringification.html
#define xstr(s) str(s)
#define str(s) #s

// XXX: Will make TUT ensure() function display the file and line that made the
// unit test fail. This header file must be included after TUT in order to make
// this hack work.
#define ensure(test) ensure(__FILE__ ":" xstr(__LINE__), test)
#endif

#endif // UTESTS_H
